#include <iostream>
#include <vector>

struct TreeNode
{
    TreeNode *left;
    TreeNode *right;
    TreeNode *mid;

    int data;

    TreeNode(int data) : data(data), left(NULL), right(NULL), mid(NULL)
    {
    }
};

int insertNode(TreeNode *root, int num)
{
    int height = 0;
    while (root)
    {
        if (num < root->data - 500)
        {
            if (root->left == NULL)
            {
                height++;
                root->left = new TreeNode(num);
                break;
            }
            else
            {
                root = root->left;
                height++;
            }
        }
        else if (num > root->data + 500)
        {
            if (root->right == NULL)
            {
                height++;
                root->right = new TreeNode(num);
                break;
            }
            else
            {
                root = root->right;
                height++;
            }
        }
        else
        {
            if (root->mid == NULL)
            {
                height++;
                root->mid = new TreeNode(num);
                break;
            }
            else
            {
                root = root->mid;
                height++;
            }
        }
    }

    return height;
}

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> nums;
    for (int i = 0; i < N; i++)
    {
        int data;
        std::cin >> data;
        nums.push_back(data);
    }

    TreeNode *head_node = new TreeNode(nums[0]);
    int max_height = 1;
    for (int i = 1; i < N; i++)
    {
        int height = insertNode(head_node, nums[i]);
        max_height = std::max(max_height, height);
    }

    std::cout << max_height + 1 << std::endl;

    return 0;
}